Open
Conversation
src/validation.coffee
Outdated
Member
There was a problem hiding this comment.
This won't work for forms that have portions inside of partials, perhaps several deep, or forms that have repeating sections which create controllers for that section.
We'll need to have a binding at the form level that will create the validation object on that controller. Here we can throw an error if the validation object doesn't exist indicating that it must be created using bind-validate or whatever we call the aggregating binding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Example usage:
Method 1
Define your validation options in your controller:
And in your HTML:
Method 2
You can define some validations right in your HTML like so:
In this example, validation options are added as
key:valueand separated with|. To add an error message to a validation option use the-eflag in the value portion of the option like so:key:value -e 'Your error message'Validation Types
Validation types can be created and defined using
validate-VALIDATION_TYPE="VALIDATION_OPTIONS"If a validation type is used but doesn't have any rules defined for it, it will pass validation but will throw a warning in the console.
Moving Forward
Would like to be able to define validation rules on the application level instead of within the validation script - some basic validation options could remain baked in, but for the most part I think it would be nice if you had to explicitly define your validation rules to suit your app.